home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / music4c.sit / Music4C Folder / orchestras / HoweExample2.c < prev    next >
Text File  |  1990-09-08  |  2KB  |  102 lines

  1. /*
  2. * ⌐ Graeme Gerrard 1990
  3. * Faculty of Music, University of Melbourne
  4. * Parkville Victoria 3052 Australia.
  5. *
  6. * ARPANET: grae@murdu.ucs.unimelb.edu.au
  7. * telephone: (613) 344 4127, Fax: (613) 344 5104
  8. */
  9. #include    "Music4C.h"
  10. #include    <math.h>
  11. #include    "ugens.h"
  12. #include    "orch.h"
  13.  
  14. #define    EXAMPLE2a    1    /* gliss instrument */
  15.  
  16. #define    EXAMPLE2b    2    /* formant instrument */
  17.  
  18. #define    MAXINS        1
  19.  
  20. static    double    *b;
  21. static    int        j[MAXINS+1];
  22. extern    FILE    *ReportFile;
  23. static    long    base;
  24. long    sampno;
  25.  
  26.  
  27.  
  28.  
  29. void initl()
  30. {
  31.     register long    k;
  32.     b = (double *)NewPtr(17 * sizeof(double));
  33.     for ( k = 0; k < 17; k++ )
  34.         *(b+k) = 0.0;
  35.     sampno = 0L;
  36. }
  37.  
  38.  
  39. void setup()
  40. {
  41. /*
  42. * Parameters for instrument 'b':
  43. * p4 = pitch level of cluster of nonharmonic partials
  44. * p5 = amp
  45. * p6 = amount of AM
  46. * p7 = speed of AM in cps
  47. * p8 = func no of shape of AM
  48. * p9 = func no indicating cluster of partials
  49. *
  50. */
  51.     switch(instype) {
  52.         case EXAMPLE2a:
  53.             break;
  54.         case EXAMPLE2b:
  55.             *b = p[6];
  56.             *(b+1) = cycle(p[7]);
  57.             j[0] = (int)p[8];
  58.             j[1] = (int)p[9];
  59.             *(b+2) = 0.0;
  60.             *(b+3) = p[5];
  61.             *(b+5) = pitch(p[4]);
  62.             linset(0.05, p[3], p[3] - 0.25, (b+9));
  63.             break;
  64.         default:
  65.             /*fprintf(stderr, "error in instrument type number, %d\n", instype);*/
  66.             ;
  67.     }
  68. }
  69.  
  70. void orch()
  71. {
  72.     register    double    x;
  73.     
  74.     switch(instype) {
  75.         case EXAMPLE2a:
  76.             break;
  77.         case EXAMPLE2b:
  78.             x = oscil(*b, *(b+1), j[0], (b+2)) + *(b+3);
  79.             x = formnt(x, *(b+5), 1, j[1], 4, 2, (b+6));
  80.             x = linens(x, (b+9));
  81. /*            output(0.0, x, 0.0, 0.0);*/
  82.             Mono(x*10000);
  83.             
  84.             break;
  85.         default:
  86.             fprintf(stderr, "error in instrument type number, %d\n", instype);
  87.     }
  88.     sampno++;
  89. }
  90. void ter()
  91. {
  92.     /* just gets called at the end a note for clean up etc. */
  93. }
  94.  
  95.  
  96. void final()
  97. {
  98. /* called at the end of the synth run.
  99. *  close any files etc. you haven't already closed here.
  100. */
  101. }
  102.